﻿@{
    Style.Require("NineSeas.Common").AtHead();
    Style.Require("NineSeas.Home").AtHead();
    Script.Require("jQuery").AtHead();
    Script.Require("MovingBox").AtFoot();
    Script.Require("NineSeas.Home").AtFoot();

    var emptyBookUrl = Href("~/Modules/NineSeas/Images/placeholder-book.png");
    var emptyAvatarUrl = Href("~/Modules/NineSeas/Images/placeholder-photo.png");
}
<div id="nineseas">
    <div id="nineseas-content" style="width: 665px;">
        <div id="home-favourite-books">
            <div class="home-featured-title">@T("Favourites")</div>
            <div class="home-featured-title-strikethrough"></div>
            <div style="clear: both; height: 10px;"></div> 
            @if (Model.BookFavouriteWeek != null)
            {           
            <div class="home-featured-books-image">
                <a href="@Url.Action("Index", "BookView", new {name = Model.BookFavouriteWeek.NameOnUrl})">
                    <img src="@(!String.IsNullOrEmpty(Model.BookFavouriteWeek.ImageUrl) ? Href("~" + Model.BookFavouriteWeek.ImageUrl) : emptyBookUrl)" 
                        alt="@Model.BookFavouriteWeek.Name" />
                </a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@T("Favourite <i>of</i> the week")</div>
                    <div class="home-featured-content">  
                        @(new MvcHtmlString(Model.BookFavouriteWeek.Introduction))
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookFavouriteWeek.NameOnUrl})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>
            <div style="clear: both; height: 10px;"></div>
            }              
            @if (Model.BookFavourite != null)
            {           
            <div class="home-featured-books-image">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookFavourite.NameOnUrl})"><img src="@(!String.IsNullOrEmpty(Model.BookFavourite.ImageUrl) ? Href("~" + Model.BookFavourite.ImageUrl) : emptyBookUrl)" 
                        alt="@Model.BookFavourite.Name" /></a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@T("Favourite <i>of</i> all time")</div>
                    <div class="home-featured-content">  
                        @(new MvcHtmlString(Model.BookFavourite.Introduction))
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookFavourite.NameOnUrl})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>
            <div style="clear: both;"></div>
            }   
        </div>
        <div id="home-most-viewed-books">
            <div class="home-featured-title">@T("Most Viewed")</div>
            <div class="home-featured-title-strikethrough"></div>
            <div style="clear: both; height: 10px;"></div> 
            @if (Model.BookMostViewedWeek != null)
            {           
            <div class="home-featured-books-image">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookMostViewedWeek.NameOnUrl})"><img src="@(!String.IsNullOrEmpty(Model.BookMostViewedWeek.ImageUrl) ? Href("~" + Model.BookMostViewedWeek.ImageUrl) : emptyBookUrl)" 
                        alt="@Model.BookMostViewedWeek.Name" /></a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@T("Most viewed <i>of</i> the week")</div>
                    <div class="home-featured-content">  
                        @(new MvcHtmlString(Model.BookMostViewedWeek.Introduction))
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookMostViewedWeek.NameOnUrl})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>
            <div style="clear: both; height: 10px;"></div>
            }              
            @if (Model.BookMostViewed != null)
            {           
            <div class="home-featured-books-image">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookMostViewed.NameOnUrl})"><img src="@(!String.IsNullOrEmpty(Model.BookMostViewed.ImageUrl) ? Href("~" + Model.BookMostViewed.ImageUrl) : emptyBookUrl)" 
                        alt="@Model.BookMostViewed.Name" /></a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@T("Most viewed <i>of</i> all time")</div>
                    <div class="home-featured-content">  
                        @(new MvcHtmlString(Model.BookMostViewed.Introduction))
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Index", "BookView", new {name = Model.BookMostViewed.NameOnUrl})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>
            <div style="clear: both;"></div>
            }   
        </div>        
        @if (Model.AuthorNewBookWeek != null)
        {   
        <div id="home-new-book-author">
            <div class="home-featured-title">@T("No. 1 <i>of</i> the week")</div>
            <div class="home-featured-title-strikethrough"></div>
            <div style="clear: both; height: 10px;"></div>         
            <div class="home-featured-avatar-image">
                        <a href="@Url.Action("Details", "Authors", new {id = Model.AuthorNewBookWeek.Id})"><img src="@(!String.IsNullOrEmpty(Model.AuthorNewBookWeek.AvatarUrl) ? Href("~" + Model.AuthorNewBookWeek.AvatarUrl) : emptyAvatarUrl)" 
                        alt="@Model.AuthorNewBookWeek.DisplayName" /></a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@Model.AuthorNewBookWeek.DisplayName</div>
                    <div class="home-featured-content home-featured-author-content">                        
                        <p>@(Model.AuthorNewBookWeek.StatusMessage)</p>
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Details", "Authors", new {id = Model.AuthorNewBookWeek.Id})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>            
        </div>
        }
        
        @if (Model.AuthorFavouriteWeek != null)
        {   
        <div id="home-favourite-author">
            <div class="home-featured-title">@T("Favourite author <i> of </i> the week")</div>
            <div class="home-featured-title-strikethrough"></div>
            <div style="clear: both; height: 10px;"></div>         
            <div class="home-featured-avatar-image">
                        <a href="@Url.Action("Details", "Authors", new {id = Model.AuthorFavouriteWeek.Id})"><img src="@(!String.IsNullOrEmpty(Model.AuthorFavouriteWeek.AvatarUrl) ? Href("~" + Model.AuthorFavouriteWeek.AvatarUrl) : emptyAvatarUrl)" 
                        alt="@Model.AuthorFavouriteWeek.DisplayName" /></a>
            </div>
            <div class="home-featured-text">
                <div class="home-featured-callout home-featured-border-callout">
                    <div class="home-featured-subtitle">@Model.AuthorFavouriteWeek.DisplayName</div>
                    <div class="home-featured-content home-featured-author-content">                        
                        <p>@(Model.AuthorFavouriteWeek.StatusMessage)</p>
                    </div>
                    <div class="home-featured-foot">
                        <a href="@Url.Action("Details", "Authors", new {id = Model.AuthorFavouriteWeek.Id})">
                            @T("more") &gt;&gt;
                        </a>
                    </div>
                    <b class="home-featured-notch"></b>
                </div>
            </div>            
        </div>
        }
        <div id="nineseas-separator"></div>
        <div id="home-books">
            <div class="scroll-button left"></div>
            <div class="scroll-button right"></div>
            <div class="home-books-slider-container">
                <div id="home-books-slider">
                @foreach (var book in Model.Books)
                {
                    var imageUrl = String.IsNullOrWhiteSpace(book.ImageUrl) ?
                        emptyBookUrl : Href("~" + book.ImageUrl);
                    <div class="home-book">
                        <a href="@Url.Action("Index", "BookView", new {name = book.NameOnUrl})">
                            <div class="home-book-image"><img src="@imageUrl" alt="@book.Name" /></div>
                            <div class="home-book-name">@book.Name</div>
                            <div class="home-book-footer">
                                <span class="home-book-likes">@(book.TotalLikes.ToString("#,#;(#,#);0"))</span>
                                <span class="home-book-views">@(book.TotalViews.ToString("#,#;(#,#);0"))</span>
                            </div>
                        </a>
                    </div>
                }
                </div>
            </div>
        </div>
    </div>
    <div id="footer-push"></div>
</div>